// pages/duobao/zjRec/zjRec.js
import S_request from '../../../utils/requestService.js';
import CONFIG from '../../../config.js';
import * as utils from '../../../utils/util.js';
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    zjList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getZJRecord();
  },
  getZJRecord: function() {
    S_request.duobao.zjRecord((result) => {
      for (let i = 0; i < result.lists.length; i++) {
        let item = result.lists[i];
        item.open_time = utils.formatTime(item.open_time, 2);
        if (item.jindu == 0) { //查看
          item.btnTitle = '查看'
          item.btnStyle = 'background-color:#f7a71f;'
        } else if (item.jindu == 1) { //处理中
          item.btnTitle = '处理中'
          item.btnStyle = 'background-color:#ec0504;'
        } else { //已发放
          item.btnTitle = '已发放'
          item.btnStyle = 'background-color:#999;'
        }
      }
      this.setData({
        zjList: result.lists
      })
    })
  },
  chakan: function(e) {
    let id = e.currentTarget.dataset.id;
    let jindu = e.currentTarget.dataset.jindu;
    if (jindu == 0) { //查看
      let type = e.currentTarget.dataset.type;
      wx.navigateTo({
        url: '../../shopExcAddr/shopExcAddr?goodId=' + id + "&type=" + type,
      })
    }
  },
  toDetail: function(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../detail/detail?id=' + id,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {
    wx.showShareMenu({
      withShareTicket: true,
      success: function() {}
    });
    let obj = { 'pagepath': CONFIG.SHARE.pathDuobao }
    S_request.index.recordShare("-6", obj);
    return {
      title: CONFIG.SHARE.titleDuobao,
      path: CONFIG.SHARE.pathDuobao,
      imageUrl: CONFIG.SHARE.imagDuobao,
      success: res => { //新版不走回调
        console.log("分享成功")
      }
    }
  },
})